<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <script>
        function showImg(item) {
            let f = item.files[0];
            // console.log(f);
            if(!f || !f.type.startsWith("image")){
                document.querySelector("#msg").innerHTML = "请选择图片";
                return;
            }
            document.querySelector("#msg").innerHTML = "";
            let url = URL.createObjectURL(f);
            document.querySelector("#show").src = url;
        }
    </script>
</head>
<body>
    <h2>注册</h2>
    <div style="color:red;font-size: 24px;" id="msg" ><?= $_REQUEST["msg"] ?></div>
    <form action="/shop/register.php" method="post" onsubmit="return checkLogin()" enctype="multipart/form-data">
        <div>
            <label>登录名: <input type="text" name="loginName"></label>
        </div>
        <div>
            <label>密码: <input type="password" name="password"></label>
        </div>
        <div>
            <label>确认密码: <input type="password" name="rePassword"></label>
        </div>
        <div>
            <label>手机号码: <input type="text" name="phone"></label>
        </div>
        <div>
            <label>头像: <input type="file" name="headImage" onchange="showImg(this)"></label>
            <img id="show" style="width: 300px;vertical-align: top;" src="" alt="暂无图片"/>
        </div>
        <div>
            <input type="submit" value="注册">
        </div>
    </form>
    <div>
        <a href="/shop/loginPage.php">有账户? 去登录</a>
    </div>
</body>
</html>